﻿using System.Collections.Generic;
using System.Linq;
using csvmb.contracts.datacontracts;
using NUnit.Framework;

namespace csvmb.csvwerk.tests
{
    [TestFixture]
    public class Teste_Datensaetze_erstellen
    {
        [Test]
        public void Aus_einer_Zeile_mit_einer_Spalte() {
            var sut = new Datensaetze_erstellen();
            IEnumerable<Datensatz> result = null;
            sut.Result += x => result = x;

            sut.Process(new[] {"a"});

            Assert.AreEqual(new[] {"a"}, result.Select(x => x.Spaltenwerte).ToArray()[0]);
        }

        [Test]
        public void Aus_einer_Zeile_mit_mehreren_Spalten() {
            var sut = new Datensaetze_erstellen();
            IEnumerable<Datensatz> result = null;
            sut.Result += x => result = x;

            sut.Process(new[] {"a;b;c"});

            Assert.AreEqual(new[] {"a", "b", "c"}, result.Select(x => x.Spaltenwerte).ToArray()[0]);
        }

        [Test]
        public void Aus_mehreren_Zeilen_mit_mehreren_Spalten() {
            var sut = new Datensaetze_erstellen();
            IEnumerable<Datensatz> result = null;
            sut.Result += x => result = x;

            sut.Process(new[] {"a;b", "c;d"});

            Assert.AreEqual(new[] {"a", "b"}, result.Select(x => x.Spaltenwerte).ToArray()[0]);
            Assert.AreEqual(new[] {"c", "d"}, result.Select(x => x.Spaltenwerte).ToArray()[1]);
        }
    }
}